public class MrMonitor {
	private String message = "";
	
	public synchronized void setMessage(String m) {
		while (!message.equals("")) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		message = m;
		notifyAll();
	}

	public synchronized String getMessage() {
		while (message.equals("")) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		String temp = message;
		message = "";
		notifyAll();
		return temp;
	}
}
